import React, { useState } from 'react'

export default function App() {
  let [r, setR] = useState(0)
  let [g, setG] = useState(255)
  let [b, setB] = useState(0)
  function changeColor(fn) {
    return e => {
      fn(e.target.value)
    }
  }
  return (
    <div>
      <p>红：<input type="range" min={0} max={255} name="" vlaue={r} onChange={changeColor(setR) }/></p>
      <p>绿：<input type="range" min={0} max={255} name="" vlaue={g} onChange={changeColor(setG)}/></p>
      <p>蓝：<input type="range" min={0} max={255} name="" vlaue={b} onChange={changeColor(setB)}/></p>
      <div style={{width: 200, height:200, border: '1px solid #ccc', backgroundColor: `rgb(${r},${g},${b})`}}></div>

    </div>
  )
}
